package com.maisonliberte.util;

public class NumberUtil {

	
    
    public static boolean isNumber(String str) {
        try {
            Double.parseDouble(str);
            return true;
        } catch(NumberFormatException e) {
            return false;
        }
    }
    
    public static String filter(String str, boolean isBreak){
    	String rt = "";
    	for(int i = 0; i < str.length(); i++){
    		if(isNumber(String.valueOf(str.charAt(i))) || str.charAt(i) == '.'){
    			rt += String.valueOf(str.charAt(i));
    		}else{
    			if(!rt.isEmpty() && isBreak) break;
    		}
    	}
    	return rt;
    }
    
    public static String changeZenToHan(String str){
    	return str.replace("０", "0").replace("１", "1").replace("２", "2").replace("３", "3").replace("４", "4").replace("５", "5").replace("６", "6").replace("７", "7").replace("８", "8").replace("９", "9");
    }

}
